// scaup - Scala up!
// (c) 2008-2010, Normen Müller, normen.mueller@gmail.com
// Original version by Jeremy Cloud (http://github.com/jjmmcc/scala0.cmdline#)
// $Id: ValidationFailure.scala 47 2010-01-12 20:22:35Z normen.mueller $
package scaup.draft.cmdln

/** ValidationFailure represents a failure while validation command line arguments.
 *  One of the subclasses will be used to indicate the specific type of failure. */
sealed trait ValidationFailure

case object NoArgumentsProvided extends ValidationFailure {
  override def toString = "No arguments provided"
}

case class FailedToMatch(spec: OptionSpec) extends ValidationFailure {
  override def toString = "Failed to match: " + spec
}

case class UnexpectedArgument(arg: String) extends ValidationFailure {
  override def toString = "Unexpected argument: " + arg
}

case class MissingArgument(arg: Argument) extends ValidationFailure {
  override def toString = "Expected argument is missing: " + arg
}

case class MissingOptionValue(option: OptionWithValue) extends ValidationFailure {
  override def toString = "Expected value for option is missing: " + option
}

case class UnexpectedFlagValue(flag: Flag, value: String) extends ValidationFailure {
  override def toString = "Value not allowed for flag: " + flag + " " + value
}

case class DuplicatedOption(option: CLOption) extends ValidationFailure {
  override def toString = "Option provided more than once: " + option
}

case class NotAnInteger(intOpt: IntOption, value: String) extends ValidationFailure {
  override def toString = "Value for " + intOpt + " is not a valid integer: " + value
}

private[cmdln] class ValidationException(val failure: ValidationFailure) extends Exception(failure.toString)
